package structure.composite;

import java.util.Vector;

public class TreeNode {
	private String name;
	private TreeNode parent;
	private Vector<TreeNode> children = new Vector<TreeNode>();

	public TreeNode() {
	}

	public TreeNode(String name) {
		this.setName(name);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public TreeNode getParent() {
		return parent;
	}

	public void setParent(TreeNode parent) {
		this.parent = parent;
	}

	public Vector<TreeNode> getChildren() {
		return children;
	}

	public void add(TreeNode node) {
		this.children.add(node);
	}

	public void remove(TreeNode node) {
		this.children.remove(node);
	}

	public void remove(String name) {
		if (name == null || name == "") {
			return;
		}
		for (TreeNode node : children) {
			if (name.equals(node.getName())) {
				remove(node);
				break;
			}
		}
	}
}
